package com.cvpoc.spring.common.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ClientController {

    protected final Log logger = LogFactory.getLog(getClass());

    @RequestMapping("/client.htm")
    public ModelAndView client(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        logger.info("returning hello view with ");

        Map<String, Object> myModel = new HashMap<String, Object>();
        myModel.put("message", "action client method");
        return new ModelAndView("InfoPage", "model", myModel);
    }
    
    @RequestMapping("/clientspecial")
    public ModelAndView clientspecial(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        logger.info("returning hello view with ");

        Map<String, Object> myModel = new HashMap<String, Object>();
        myModel.put("message", "action client special method");
        return new ModelAndView("InfoPage", "model", myModel);
    }
    
    @RequestMapping("/customer/{userId}/{actionId}")
    public ModelAndView parametres(@PathVariable String userId, @PathVariable String actionId)
            throws ServletException, IOException {

        logger.info("returning hello view with ");

        Map<String, Object> myModel = new HashMap<String, Object>();
        myModel.put("message", "action client special method : " + userId + " | " + actionId);
        return new ModelAndView("InfoPage", "model", myModel);
    }
}
